#!/usr/bin/env python
# vim:fileencoding=utf-8

from calibre.web.feeds.news import BasicNewsRecipe


class Zerkalo(BasicNewsRecipe):
    title = '\u0414\u0437\u0435\u0440\u043A\u0430\u043B\u043E \u0442\u0438\u0436\u043D\u044F. \u0423\u043A\u0440\u0430\u0457\u043D\u0430'
    __author__ = 'bugmen00t'
    description = '\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0435 \u0456\u043D\u0442\u0435\u0440\u043D\u0435\u0442-\u0432\u0438\u0434\u0430\u043D\u043D\u044F, \u0441\u0443\u0441\u043F\u0456\u043B\u044C\u043D\u043E-\u043F\u043E\u043B\u0456\u0442\u0438\u0447\u043D\u0438\u0439 \u0442\u0438\u0436\u043D\u0435\u0432\u0438\u043A.'  # noqa: E501
    publisher = '\u0414\u0437\u0435\u0440\u043A\u0430\u043B\u043E \u0442\u0438\u0436\u043D\u044F. \u0423\u043A\u0440\u0430\u0457\u043D\u0430'
    category = 'newspaper'
    cover_url = u'https://zn.ua/user/img/zn_no_photo_amp.png'
    language = 'uk'
    no_stylesheets = False
    remove_javascript = False
    auto_cleanup = False
    remove_empty_feeds = True
    oldest_article = 7
    max_articles_per_feed = 200

    remove_tags_before = dict(name='h1')

    remove_tags_after = dict(name='div', attrs={'class': 'article_body'})

    remove_tags = [
        dict(name='span', attrs={'class': 'print print-art-js'}),
        dict(name='div', attrs={'class': 'questionnaire '}),
        dict(name='div', attrs={'class': 'nts-video-wrapper'}),
        dict(name='div', attrs={'class': 'telegram'}),
        dict(name='div', attrs={'class': 'mist_block'}),
        dict(name='div', attrs={'class': 'auth_articles_block'}),
        dict(name='div', attrs={'class': 'special_theme_news_block'}),
        dict(name='div', attrs={'class': 'article_attached acenter'}),
        dict(name='div', attrs={'class': 'article_left'}),
        dict(name='div', attrs={'class': 'top_social_holder'})
    ]

    feeds = [
        ('\u041D\u043E\u0432\u0438\u043D\u0438', 'https://zn.ua/ukr/rss/full.rss'),
        #       ('\u0421\u0442\u0430\u0442\u0442\u0456', 'https://zn.ua/ukr/rss/articles.rss')
    ]

    def preprocess_html(self, soup):
        for img in soup.findAll('img', attrs={'data-src': True}):
            img['src'] = img['data-src']
        return soup
